<template>
	<el-cascader filterable clearable :options="options" v-model="contentValue" :props="{
					value: 'id',
					label: 'cat_name',
					leaf: 'isLeaf',
					emitPath: false,
				}" placeholder="请选择或搜索">
	</el-cascader>
</template>

<script>
	export default {
		data() {
			return {
				options: []
			};
		},
		mounted() {
			this.getTree()
		},
		props: {
			modelValue: {
				type: String,
				default: ""
			},
			apiUrl: {
				type: String,
				default: "system/category/manage"
			},
			model: {
				type: String,
				default: ""
			}
		},
		computed: {
			contentValue: {
				get() {
					return this.modelValue
				},
				set(val) {
					this.$emit('update:modelValue', val);
				}
			}
		},
		methods: {
			async getTree() {
				var res = await this.$API.system.commPost(this.apiUrl + "/tree")({
					model: this.model
				})
				this.options = res.data;
			}
		}
	};
</script>
